<template>
  <div class="tabbar">
    <div class="top">
      <div class="title">气象数据可视化系统</div>
      <el-icon :size="25" @click="isShow" class="icon"><Search /></el-icon>
      <mySearch v-show="showSearch" />
    </div>
    <div class="tab">
      <div class="city">{{ city }}</div>
      <div class="choose">
        <el-row justify="space-evenly">
          <el-col :span="4">
            <Content title="天气" routeName="/main" />
          </el-col>
          <el-col :span="5">
            <Content title="30天预报" routeName="/weather30" />
          </el-col>
          <el-col :span="5">
            <Content title="空气质量" routeName="/air" />
          </el-col>
          <el-col :span="5">
            <Content title="生活指数" routeName="/indices" />
          </el-col>
          <el-col :span="5">
            <Content title="历史数据" routeName="/historical" />
          </el-col>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script setup>
import mySearch from "../search/mysearch.vue";
import Content from "./content.vue";

import usePublicStore from "@/stores/modules/public";
import { storeToRefs } from "pinia";

const publicStore = usePublicStore();

publicStore.fetchIP();

const { city, showSearch } = storeToRefs(publicStore);

const isShow = () => {
  showSearch.value = !showSearch.value;
};
</script>

<style lang="less" scoped>
.tabbar {
  max-width: 1180px;
  margin: 0 auto;
  .top {
    position: relative;
    .title {
      margin: 0 auto;
      height: 30px;
      font-size: 25px;
      line-height: 30px;
      font-weight: 700;
      text-align: center;
      align-items: center;
    }
    .icon {
      position: absolute;
      top: 5px;
      right: 7px;
    }
  }
  .tab {
    display: flex;
    margin-top: 5px;
    .city {
      margin-left: 5px;
      width: 80px;
      text-align: left;
      align-items: center;
      height: 40px;
      line-height: 40px;
      font-size: 25px;
    }
    .choose {
      flex: 1;
      margin: 0 auto;
      background-color: #e7eefd;
      max-width: 1180px;
      margin-bottom: 20px;
      border-radius: 20px;
    }
  }
}
</style>